The present invention relates generally to an input module and, more particularly, an algorithm for filtering noise and transient from the input signals of an input module.
Input modules are usually classified as discrete input modules and analog input modules. Analog input modules are used to process signals from field devices such as pressure, level, temperature and weight sensors into numerical data. Discrete input modules are used to convert signals from field devices such as pushbuttons, limit and proximity switches, and photo sensors into signals that can be used by a signal processor commonly known in the automation industry as a programmable logic controller (PLC). Typically, an input module has an output linking to one end of a field device to provide power to the field device, and an input linking to the other end of the field device to receive signals therefrom, as shown in FIG. 1. In particular, a discrete input module applies a voltage to the field device while an analog input module provides a current to the field device.
Modicon presently produces and markets a variety of input modules. Among these Modicon input modules, discrete modules come with many different supplied voltage levels: 115 VAC, 230 VAC, 24 VDC, 24 VAC/VDC, 48 VAC/VDC, 125 VDC, 5V TTL, etc. When a field device such as an ON/OFF switch is used to connect to a 24 VDC discrete module, for example, the voltage at the input of the input module is either 24 VDC or 0 VDC in an ideal situation. From the received input voltage at the input module, it is possible to determine when the switch is switched ON or OFF. However, the input signals usually contain noise, transients, voltage drift and other unwanted components, and these unwanted components may distort the waveform of the input signals and render the switching timing measurement difficult.
In an AC input module, the received signals may also contain other unwanted components which are due to the zero-crossing of the AC voltage. It is necessary to filter out these transients, noise and zero-crossing induced spikes in the signals. Furthermore, the voltage at the input of an input module is in the form of AC signals when the switch is operated at the ON state. Preferably, the received signals be converted into a binary waveform so that the switching timing can be determined more easily.
Presently, the filtering process of an AC input line uses a sampling method to sample the binary waveform at a fixed sample rate to produce a filtered ON input state and a filtered OFF input state. The filtering algorithm is determined based on the characteristics of the input module. For a 120VAC module, the input line is full-wave rectified to produce a binary waveform having a HIGH period and a LOW period, depending on the root-means squared voltage (VRMS) of the input line, as shown in TABLE 1.
It should be noted that the sum of the HIGH time and the corresponding LOW time for an input voltage 50 VRMS or higher is equal to 8.4 msec. This sum is derived from the 60 Hz cycle of the AC voltage.
The basic idea of the filtering process is to produce a filtered ON state whenever a HIGH state lasts at least 6 msec and a filtered OFF state whenever a continuous 6 msec HIGH state is absent over a period of 8.4 msec. With a sampling rate of one sample every 0.3 msec, the number of samples within the minimum 6 msec of HIGH time period is 20. Similarly, the number of samples within the 8.4 msec absence of the HIGH state is 28. In order to keep track of the HIGH and LOW time periods, a counter is used to record the sampling result. Because the minimum continuous HIGH time (6 msec) to produce a filtered ON state and the continuous minimum OFF time (8.4 msec) to produce a filtered OFF state are not equal, one cannot simply use an UP/DOWN counter to keep track of the HIGH and LOW time periods. Mathematically, one must use a common multiple of 20 and 28 as a maximum count to set the filtered input state to ON. The Lowest Common Multiple of 20 and 28 is 140. If a counter is used to keep track of the sampling results, one would add 7 to the counter every time the sampling occurs at the HIGH state and subtract 5 from the counter every time the sampling occurs at the LOW state. By doing so, when the reading on the counter has reached 136, the filtered input state can be set to ON. When the reading on the counter has been reduced to 0, the filtered input state can be set to OFF.
In consideration of the limited space in the input module memory, however, it is desirable to have a smaller maximum count to set the filtered input state to ON. When hysteresis of the rectifier circuit is taken into account and a sampling time of 0.1 msec is used, the acceptable smallest number to be used as an approximate lowest common multiple of 20 and 28 is 60. As a counter is used to keep track of the sampling results, an increment of 3 (=60/20) on the counter reading is made every time the sampling occurs at the HIGH state and a decrement of 2 (xcx9c60/28) on the counter reading every time the sampling occurs at the LOW state. Accordingly, when the reading on the counter has reached 57, the filtered input state can be set to ON. Likewise, when the reading on the counter has been reduced to 0, the filtered input state can be set to OFF.
Thus, the software algorithm is as follows:
if input is HIGH and if the number of counts is equal to or greater than 57, set filtered state to
On else add 3 to the counter
else if the number of counts is equal to or less than 0, set filtered state to OFF else subtract 2 from the counter.
This algorithm is illustrated in FIG. 4.
The filtering algorithm is determined by the rate at which the input line can be sampled and the amount of time a pulse of the rectified waveform remains HIGH or LOW in a cycle. Therefore, the maximum count, increment count and decrement count in the software algorithm to be used with one input module are different from those for another input module, as shown in TABLE 2.
The filtering algorithm for 240VAC isolated 16PT input module and 24VAC 16/32PT input module is as follows:
if input is HIGH and if the number of counts is equal to or greater than 60, set filtered state to ON else add 4 to the counter
else if the number of counts is equal to or less than 0, set filtered state to OFF else subtract 2 from the counter.
The above algorithm is illustrated in FIG. 5. Presently, hardware jumpers are used to select the filter parameters Max Count, Increment Count and Decrement Count for a different type of input module.
In an automation island where a large number of different input modules are used to carry out different tasks, each different input module has its own unique filtering algorithm to suit the electrical characteristics of the input module. Furthermore, each different input module has its own input sample rate, different port pins and filter rate.
It is advantageous and desirable to provide a single filter algorithm that can be used by a variety of different input modules.
It is an object of the present invention to provide a method for filtering an input signal received by an input module from a field device, wherein one filtering algorithm can be used by a variety of different input modules.
It is another object of the present invention to provide an input module which is adapted to receive and filter input signals using a common filtering algorithm that can also be used by other different input modules.
The method, according to the present invention, is used to filter an input signal in order to produce a filtered input signal, wherein the received input signal is converted such that it has either a HIGH input state or a LOW input state each having a time duration characteristic of the input module, and the filtered input signal is represented by an ON filtered state and an OFF filtered state, and wherein the method determines the time duration of the HIGH input state and the LOW input state by way of sampling at a sampling rate, and uses a counter to keep track of the sampling results in order to set the filtered input state to ON or OFF. The method includes using a filtering algorithm to carry out the following logical steps for each sample:
1) increasing the counter reading by an increment count if the input signal is HIGH at the time of sampling and the counter reading is smaller than a maximum count;
2) setting the filtered input state to ON if the input signal is HIGH at the time of sampling and the counter has reached the maximum count;
3) decreasing the counter reading by a decrement count if the input signal is LOW at the time of sampling and the counter reading is greater than a minimum count; and
4) setting the filtered input state to OFF if the input signal is LOW at the time of sampling and the counter has been reduced to the minimum count, wherein the filter parameters of maximum count, increment count and decrement count can be electronically selected so that the same filtering algorithm can be used for a plurality of different input modules having different electrical characteristics.
Accordingly, the input module of the present invention includes a device for storing the filtered input state; a device for storing filter parameters; a device for storing a filter algorithm; a counter having a reading to keep track of sampling results; and a logic unit to determine whether the input signal is HIGH or LOW at the time of sampling, so as to allow the filter algorithm to carry out the logical steps. The input module is configurable so that the filter parameters can be electronically selected to suit the characteristics of the input module.
The present invention will become apparent upon reading the descriptions taken in conjunction with FIGS. 1 to 5.